<!DOCTYPE html>
<html lang="en">
<head>
    <title>首页</title>
    <meta http-equiv="description" content="" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="${base}/static/res/manage/css/common.css" type="text/css" />
    <link rel="stylesheet" href="${base}/static/res/manage/css/newInf.css" type="text/css" />
    <link rel="stylesheet" href="${base}/static/res/manage/css/login.css" type="text/css" />
    <script type="text/javascript" src="${base}/static/res/manage/js/jquery.js"></script>
    <script type="text/javascript" src="${base}/static/res/plugin/validator/jquery.validate.min.js"></script>
    <script type="text/javascript" src="${base}/static/res/util/security.js"></script>
    <script type="text/javascript" src="${base}/static/res/admin/js/common.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            // 获取表单数据
            var $enPassword = $("#enPassword");
            var $loginName = $("#loginName");
            var $password = $("#password");

            // 登录提示信息
            // var loginFailure = $("shiroLoginFailure");
            // var shiroMsg = "";
            // if (loginFailure != null) {
            //     if (loginFailure.equals("org.apache.shiro.authc.pam.UnsupportedTokenException")) {
            //         shiroMsg = "验证码错误!";
            //     } else if (loginFailure.equals("org.apache.shiro.authc.UnknownAccountException")) {
            //         shiroMsg = "此账号不存在!";
            //     } else if (loginFailure.equals("org.apache.shiro.authc.DisabledAccountException")) {
            //         shiroMsg = "此账号已被禁用!";
            //     } else if (loginFailure.equals("org.apache.shiro.authc.LockedAccountException")) {
            //         shiroMsg = "此账号已被锁定";
            //     } else if (loginFailure.equals("org.apache.shiro.authc.IncorrectCredentialsException")) {
            //         shiroMsg = "密码错误，若连续5次输入错误账号将被锁定!";
            //     } else if (loginFailure.equals("org.apache.shiro.authc.AuthenticationException")) {
            //         shiroMsg = "账号认证失败!";
            //     }
            // }
            // if (shiroMsg != "") {
            //     showTips(shiroMsg);
            // }

            // 图片验证码刷新
            // $("#captchaImage").click(function () {
            //    $(this).attr("src", "<%=base%>/intfc/config/captcha.jhtml?captchaId= <%=captchaId%>");
            // });

            //字段校验
            $("#loginForm").validate({
                rules: {
                    loginName: {
                        required: true,
                        mobile: true
                    }
                },
                messages: {
                    loginName: {
                        mobile: "帐号格式错误",
                        required: "帐号不能为空"
                    }
                },
                showErrors: function (errorMap, errorList) {
                    if (errorList != null && errorList.length > 0) {
                        if (errorList != null && errorList.length > 0) {
                            showTips(errorList[0].message);
                        }
                    }
                },
                submitHandler: function (form) {

                    if ($password.val() == "") {
                        showTips("密码不能为空!");
                        return;
                    }

                    // js rsa 加密
                    // var publicKey = RSAUtils.getKeyPair("<%=exponent%>", '', "<%=modulus%>");
                    // var enPassword = RSAUtils.encryptedString(publicKey, $password.val());

                    // 设置加密后的值

                    $enPassword.val($("#password").val());

                    // 提交表单数据
                    $(form).find(":submit").prop("disabled", true);


                    // ******** 如下为测试异步登录 ********** //

                    var pwd = $("#password").val();
                    var name = $("#loginName").val();

                    $.post("/admin/common/login1.jhtml",{'enPassword':pwd,'loginName':name},function (data) {
                        debugger;
                        alert(data);
                        location.href = "/admin/common/main.jhtml";
                    });



                    // ******* 测试异步结束 ************//
                    //form.submit();
                }
            });
        });

        // 展示提示信息
        function showTips(tips) {
            $("div.tip-msg").show().find("p").html(tips);
        }
    </script>
</head>
<body class="login center-y">
<div class="loginTxt">
    <!-- 主体 -->
    <div class="mainLogin">
         <!-- 隐藏域 -->
        <form id="loginForm" action="" method="post">
            <input type="hidden" id="enPassword" name="enPassword"/>
            <#--<input type="hidden" name="captchaId" value="<%=captchaId%>"/>-->
         <!-- 背景图 -->
        <div class="mainLoginL">
            <div class="mainLImg"><img src="${base}/static/res/manage/images/login/imgL.jpg" /> </div>
        </div>
        <div class="mainLoginR">
            <div class="mainRLogo"><img src="${base}/static/res/manage/images/index/logo.png" /></div>
            <div class="mainRH">账户登录</div>
            <!-- 用户名 -->
            <div class="mainRTxt center-y">
                <div class="mainRImg"><img src="${base}/static/res/manage/images/login/user.png" /></div>
                <div class="mainRIn">
                    <input type="text" placeholder="请输入手机号" name="loginName" id="loginName" maxlength="11">
                </div>
            </div>
            <!-- 密码 -->
            <div class="mainRTxt center-y">
                <div class="mainRImg"><img src="${base}/static/res/manage/images/login/pass.png" /></div>
                <div class="mainRIn">
                    <input type="password" placeholder="请输入密码" id="password">
                </div>
            </div>
            <!-- 验证码 -->
           <#--<div class="mainRTxt center-y">-->
                <#--<div class="mainRImg"><img src="<%=base%>/intfc/res/manage/images/login/code.png" /></div>-->
                <#--<div class="mainRCode center-y">-->
                    <#--<input type="text" placeholder="请输入验证码" name="captcha" id="captcha">-->
                    <#--<img title="点击刷新验证码" id="captchaImage"-->
                         <#--src="<%=base%>../intfc/config/captcha.jhtml?captchaId=<%=captchaId%>"/>-->
                <#--</div>-->
            <#--</div>-->
            <!-- 提示 -->
            <div class="tip-msg" style="display:none;">
                <img src="${base}/static/res/manage/images/index/error.png" alt="">
                <p></p >
            </div>
            <!-- 登录 -->
            <div class="mainRBtn">
                <button type="submit" value="登录">
            </div>
        </div>
        </form>
    </div>
    <!-- 底部 -->
    <footer class="footerLogin">
        <p>
             ${setting.copyRight}
            <span> 客服电话 ${setting.servicePhone}></span>
        </p>
    </footer>
</div>
</body>
</html>